var app = sm("do_App");
var page = sm("do_Page");
var nf = sm("do_Notification");
var http = require("helper/http");
var hiUrl = require("url/hi");
var helperOpen = require("helper/open");

// 社区头部
var headerAout = ui("headerAout");
var addheader = headerAout.add("header", "source://view/reuse/header.ui", 0, 0);
ui(addheader+".labelTitle").text = "我的等级";
//左上角-返回
var headerLeft = ui(addheader+".headerLeft");
headerLeft.on("touch", function() {
    app.closePage();
});
var headerRight = ui(addheader + ".headerRight");
//右上角添加+图标
var imgNext = ui(addheader + ".imgNext");
imgNext.source = "source://image/header/question.png";
imgNext.visible = true;
//andriod返回键
page.on("back", function() {
    app.closePage();
});
headerRight.on("touch", function() {
	helperOpen.open("source://view/honor/rule/index.ui");
});
var listdata = mm("do_ListData");
var listView = ui("listView");
listView.bindItems(listdata);

var datas = [{"img":"source://image/honor/icon01.png","name":"荣誉称号","content":"不同等级有不同的专属名称和标识哦"},
             {"img":"source://image/honor/icon02.png","name":"荣誉排行榜","content":"社区排名前50的用户可以到社区排行榜，快提升等级让更多邻居认识你吧"},
             {"img":"source://image/honor/icon03.png","name":"认证权限","content":"通过居民认证享受圈圈更多权益（敬请期待）"},
             {"img":"source://image/honor/icon04.png","name":"创建圈子权限","content":"创建圈子，认识更多志同道合的朋友吧（敬请期待）"},
             {"img":"source://image/honor/icon05.png","name":"专属购物优惠","content":"圈圈商城专属等级优惠券等你拿。等级越高优惠越多哦（敬请期待）"}]
function laodPage() {
	listdata.removeAll();
	listView.refreshItems();
	http.post(hiUrl.url.honorLevel.myLevel, {}, function(data) {
		var myLevel = data.myLevel;	
		myLevel.honorStr = "当前荣誉值："+ data.myLevel.honorValue;
		myLevel.imgvb = "source://image/honor/"+myLevel.level+".png";
		myLevel.imgvf = "source://image/honor/"+myLevel.level+".png";
		myLevel.imgvl = "source://image/honor/"+myLevel.nextLevel+".png";
		listdata.addOne({
			"template": 1,"myLevel":myLevel
		});
		listdata.addData(datas);
		listView.refreshItems();
	});
	
}
laodPage();



//下拉列表，刷新数据
listView.on("pull", function(data) {
	if (data.state == 2) {
		listView.rebound();
	}
});
// 上拉列表，翻页数据
listView.on("push", function(data) {
	if (data.state == 2) {
		listView.rebound();
	}
});